package com.wl;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;

import com.wl.interceptor.UserSecurityInterceptor;
import com.wl.listener.ContextListener;

@SpringBootApplication
public class GirlApplication {

	public static void main(String[] args) {
		SpringApplication.run(GirlApplication.class, args);
	}
	
	/**
	 * 注册过滤器
	 * 2017年4月12日
	 * wl
	 * @return
	 */
	/*
	@Bean
    public FilterRegistrationBean filterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        System.out.println("注册sessionFilter");
        registration.setFilter(new SessionFilter());
        registration.addUrlPatterns("/*");
        registration.setName("sessionFilter");
        return registration;
    }
	
	@Bean
	public FilterRegistrationBean filterRegistration2() {
		FilterRegistrationBean registration = new FilterRegistrationBean();
		System.out.println("注册myFilter");
		registration.setFilter(new MyFilter());
		registration.addUrlPatterns("/hello");
		registration.setName("myFilter");
		return registration;
	}
	*/
	
	/**
	 * 注册监听器
	 * 2017年4月12日
	 * wl
	 * @return
	 */
	@Bean
	public ServletListenerRegistrationBean<?> servletListenerRegistration() {
		ServletListenerRegistrationBean<ContextListener> registration = new ServletListenerRegistrationBean<ContextListener>();
		registration.setListener(new ContextListener());
		return registration;
	}
	
	/**
	 * 注册拦截器
	 * 2017年4月12日
	 * wl
	 * @return
	 */
	@Bean
	public InterceptorRegistration interceptorRegistration() {
		InterceptorRegistration registration = new InterceptorRegistration(new UserSecurityInterceptor());
		registration.addPathPatterns("/*");
		return registration;
	}
	
	
}
